
package com.product.android.business.bean;

import java.io.Serializable;

import android.database.Cursor;

/**
 * 用户信息
 * 
 * @author yiyang
 */
public class UserInfo implements Serializable {

    private static final long serialVersionUID = 6504627686859795470L;

    // 用户ID
    private long mUap_uid;

    // 登录帐号
    private String mUser_name;

    // 昵称
    private String mUser_nick_name;

    // 密码(RSA加密的)
    private String mUser_pass;

    // 密码(MD5加密的)
    private String mUser_pass_md5;

    // 是否记住密码
    private boolean mIs_save_account;

    // 是否自动登陆
    private boolean mIs_auto_login;

    // 最后一次登陆日期
    private String mLast_login_dt;

    // OAP单位ID
    private int mOap_unit_id;

    // OAPID
    private long mOap_uid;

    // 登录sid
    private String mSid;
    
    // 扩展字段
    private String mVar_ext;
    
    //判断是否是手机登陆， 0 否， 1 是
    private int mIs_phone;

    //混淆后的MD5密码
    private String mUser_pass_mixed_md5;

    //票据
    private String mTicket;
    
    //和票据一共使用的随机字符串（在获取票据时作为参数传入）
    private String mBlowfish;
    
    //是否机构管理员
    private int mIsOrgAdmin=0;
    
    // 身份信息，1：职员 2：学生 3：家长
 	private int mIdentity;
    
    //以下字段为明星APP专用
    public int sex;		//0 保密 1 男 2 女
    public int prestige;//威望
    public int wealth;	//财富
    public int grade;	//等级
    public int flower;	//鲜花
    public String realname;		//真实姓名
    public String uniquename;	//昵称
    public long dataline;		//登陆时间戳
    
    public int getIs_phone() {
		return mIs_phone;
	}

	public void setIs_phone(int mIs_phone) {
		this.mIs_phone = mIs_phone;
	}

	public UserInfo() {
        init();
    }

    public void init() {
        mUser_name = "";
        mUser_pass = "";
        mUser_pass_md5="";
        mUser_pass_mixed_md5="";
        mTicket="";
        mBlowfish="";
        mSid = "";
        mUser_nick_name = "";
        mIs_save_account = true;
        mIs_phone = 0;
    }

    public boolean LoadFormCursor(Cursor cur) {
        boolean breturn = false;
        mUap_uid = cur.getLong(cur.getColumnIndex("UAP_UID"));
        mUser_name = cur.getString(cur.getColumnIndex("USER_NAME"));
        mUser_nick_name = cur.getString(cur.getColumnIndex("USER_NICK_NAME"));
        mUser_pass = cur.getString(cur.getColumnIndex("USER_PASS"));
        mUser_pass_md5 = cur.getString(cur.getColumnIndex("USER_PASS_MD5"));
        int index = cur.getColumnIndex("USER_PASS_MIXED_MD5");
        if(index != -1){
            mUser_pass_mixed_md5 = cur.getString(index);
        }
        index = cur.getColumnIndex("BLOWFISH");
        if(index != -1){
            mBlowfish=cur.getString(index);
        }
        index = cur.getColumnIndex("TICKET");
        if(index != -1){
            mTicket=cur.getString(index);
        } 

        mIs_save_account = "true".equals(cur.getString(cur.getColumnIndex("ISSAVEACCOUNT")));
        mIs_auto_login = "true".equals(cur.getString(cur.getColumnIndex("ISAUTOLOGIN")));
        mLast_login_dt = cur.getString(cur.getColumnIndex("LAST_LOGIN_DT"));
        mOap_unit_id = cur.getInt(cur.getColumnIndex("OAP_UNIT_ID"));
        mOap_uid = cur.getLong(cur.getColumnIndex("OAP_UID"));
        mVar_ext = cur.getString(cur.getColumnIndex("VAR_EXT"));
        mIs_phone =  cur.getInt(cur.getColumnIndex("ISPHONE"));
        
        index = cur.getColumnIndex("ISADMIN");
        if(index != -1){
            mIsOrgAdmin= cur.getInt(index);
        }
        
        index = cur.getColumnIndex("IDENTITY");
        if(index != -1){
        	mIdentity= cur.getInt(index);
        }
        
        getStarAppData(cur);
        return breturn;
    }
    
    /**
     * @n<b>函数名称</b>     :getStarAppData
     * @brief 从cursor中获取明星app的数据
     * @version    Ver 1.0.0
     * @param  @param cur
     * @return void
     * @<b>作者</b>          :  cb
     * @<b>创建时间</b>      :  2014-4-10下午2:19:00      
    */
    private void getStarAppData(Cursor cur){
    	int index = cur.getColumnIndex("sex");		//0 保密 1 男 2 女
    	if (index<0){
    		return;
    	}
    	sex=cur.getInt(index);
        index = cur.getColumnIndex("prestige");//威望
        prestige=cur.getInt(index);
        index = cur.getColumnIndex("wealth");	//财富
        wealth=cur.getInt(index);
        index = cur.getColumnIndex("grade");	//等级
        grade=cur.getInt(index);
        index = cur.getColumnIndex("flower");	//鲜花
        flower=cur.getInt(index);
        index = cur.getColumnIndex("realname");		//真实姓名
        realname=cur.getString(index);
        index = cur.getColumnIndex("uniquename");	//昵称
        uniquename=cur.getString(index);
    }

    public String getmVar_ext() {
		return mVar_ext;
	}

	public void setmVar_ext(String mVar_ext) {
		this.mVar_ext = mVar_ext;
	}

	public long getUapUid() {
        return mUap_uid;
    }

    public String getUserName() {
        return mUser_name;
    }

    public String getUserNickName() {
        return mUser_nick_name;
    }

    public String getUserPass() {
        return mUser_pass;
    }

    public String getUserPassMd5() {
        return mUser_pass_md5;
    }

    public boolean getIsSaveAccount() {
        return mIs_save_account;
    }

    public boolean getIsAutoLogin() {
        return mIs_auto_login;
    }

    public String getLastLoginDt() {
        return mLast_login_dt;
    }

    public String getSessionId() {
        return mSid;
    }

    public long getOapUid() {
        return mOap_uid;
    }

    public int getOapUnitId() {
        return mOap_unit_id;
    }
    
    public String getUserPassMixedMd5(){
    	return mUser_pass_mixed_md5;
    }
    
    public String getBlowfish(){
    	return mBlowfish;
    }
    
    public String getTicket(){
    	return mTicket;
    }
    
    public int getIsAdmin(){
    	return mIsOrgAdmin;
    }
    
    public void setUapUid(long uid) {
        mUap_uid = uid;
    }

    public void setUserName(String name) {
        mUser_name = name;
    }

    public void setUserNickName(String nickname) {
        mUser_nick_name = nickname;
    }

    public void setUserPass(String pass) {
        mUser_pass = pass;
    }

    public void setUserPassMd5(String pass) {
        mUser_pass_md5 = pass;
    }

    public void setIsSaveAccount(boolean isSave) {
        mIs_save_account = isSave;
    }

    public void setIsAutoLogin(boolean isAuto) {
        mIs_auto_login = isAuto;
    }

    public void setLastLoginDt(String dt) {
        mLast_login_dt = dt;
    }

    public void setSessionId(String sid) {
        mSid = sid;
    }

    public void setOapUid(long uid) {
        mOap_uid = uid;
    }

    public void setOapUnitId(int unitid) {
        mOap_unit_id = unitid;
    }
    
    public void setUserPassMixedMd5(String pass){
    	mUser_pass_mixed_md5=pass;
    }
    
    public void setBlowfish(String fish){
    	mBlowfish=fish;
    }
    
    public void setTicket(String ticket){
    	mTicket=ticket;
    }
    
    public void setIsOrgAdmin(int value){
    	mIsOrgAdmin=value;
    }
    
    public int getIdentity() {
		return mIdentity;
	}

	public void setIdentity(int identity) {
		mIdentity = identity;
	}
}
